import React from "react"

function Demo(){
    const myInput = React.useRef()

    function getInputVal(){
        console.log(myInput.current.value);
    }

    return (
        <div>
            <input type="text" ref={myInput}/>
            <button onClick={getInputVal}>获取输入框的值</button>
        </div>
    )
}

export default Demo